package com.seuic.hnjiningposapp.hnapps.ui.view.dialog;

import android.app.Activity;
import android.content.Context;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.lxj.xpopup.core.CenterPopupView;
import com.seuic.hnjiningposapp.R;
import com.seuic.hnjiningposapp.hnapps.util.GetMoneyLvUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

public class DealSuccessPopup extends CenterPopupView {//交易成功弹窗
    Context context;
    Activity activity;
    Unbinder bind;
    ClickCallback callevent;
    @BindView(R.id.switch_success_name)
    TextView switchSuccessName;
    @BindView(R.id.switch_success_usernum)
    TextView switchSuccessUsernum;
    @BindView(R.id.switch_success_usernmae)
    TextView switchSuccessUsernmae;
    @BindView(R.id.switch_success_dealtype)
    TextView switchSuccessDealtype;
    @BindView(R.id.switch_success_okbtn)
    Button switchSuccessOkbtn;


    String money;
    String type;
    String cardnum;
    String username;

    public DealSuccessPopup(@NonNull Context context, Activity activity, ClickCallback callevent) {
        super(context);
        this.context = context;
        this.activity = activity;
        this.callevent = callevent;
    }

    @OnClick(R.id.switch_success_okbtn)
    public void onViewClicked() {
        callevent.OKPrint();
    }

    public interface ClickCallback {
        void OKPrint();
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.dialog_dealsuccess;
    }

    public void setMoney(String money) {
        this.money = money;
    }

    public void setType(String type) {
        this.type = type;
    }

    public void setCardnum(String cardnum) {
        this.cardnum = cardnum;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        bind = ButterKnife.bind(this);
        switchSuccessName.setText(type);
        switchSuccessUsernum.setText(cardnum);
        switchSuccessUsernmae.setText(username);
        switchSuccessDealtype.setText(GetMoneyLvUtils.getInputMoney(money));

    }

    protected void onShow() {
        super.onShow();
    }

    @Override
    protected void onDismiss() {
        super.onDismiss();
        //注解解绑
        if (bind != null && bind != Unbinder.EMPTY) {
            bind.unbind();
        }
        this.bind = null;
    }

    String data;

    public void setContent(String s) {
        data = s; //只记录数据，不再操作View
    }
}